﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="OAclient.Common" %>

<script type="text/javascript">
    $(function() {
        $(".datepicker").datepicker();
        $("#searchclrname_wffinish").autocomplete({
            source: function(request, response) {
                $.ajax({
                    url: "/Home/SearchUserFormAll",  //要查询的Action
                    type: "POST",  //Post提交
                    dataType: "json", //json格式数据，默认是text
                    data: { keyword: request.term }, //参数，不知道为什么？请指点
                    success: function(data) {
                        response($.map(data, function(item) {
                            return { label: item.text, value: item.value }; //将返回的jsonresult的属性赋值给autocomplete item
                        }))
                    }
                })
            },
           select: function(event, ui) {
                var t=ui.item.label;//'马军 事业部 员工'
                var arr= t.split(' ');
                $('#searchclrname_wffinish').val(arr[0]);  //选中item的文本
                $('#searchclrid_wffinish').val(ui.item.value); //选中item的值
                return false;
            },
            minLength:'0',
        })
        
        tableSelectOrder("#wffinishlist .table_style");
    });
    
        function checkProcedure(uniqueId) {
        $.ajax({
            type: "POST",
            url: "/WorkFlow/DoGetTaskFlowChart",
            data: { "uniqueId": uniqueId },
            success: function(data) {
                addtab('2-5', '查看流程');
                var workarea = $("#workarea-2-5").html("<div id='procedure'></div>");
                var procedure = $(workarea).children("#procedure");
                var drag = $.fn.Procedure({ renderTo: procedure, inititedata: data });
            }
        });
    }
</script>

<script type="text/javascript">

    $(function() {
        var wffinishlistoptions = {
            url: "/WorkFlow/WFFinishList",
            type: "POST",
            success: function(data) {
                $("#workarea-2-4").html(data);
            }
        };

        $("#frmwffinishlist").ajaxForm(wffinishlistoptions);
    })
</script>

<div id="wffinishlist" style="padding-top: 35px;">
    <%using (Html.BeginForm("WFFinishList", "WorkFlow", FormMethod.Post, new { id = "frmwffinishlist" }))
      {%>
    <div class="selectpanel" style="margin: 5px 20px 5px 70px;">
        申请单名称:
        <%=Html.DropDownList("searchwfname_wffinish", ViewData["wfnamelist"] as List<SelectListItem>, "======请选择======", null)%>
        经手人:
        <%=Html.TextBox("searchclrname_wffinish")%>
        <%=Html.Hidden("searchclrid_wffinish")%>
        时间:
        <%=Html.TextBox("searchstime_wffinish", "", new { @class = "datepicker" })%>
        -
        <%=Html.TextBox("searchetime_wffinish", "", new { @class = "datepicker" })%>
        <input class="btn_style" type="submit" value="查询" name="submit" />
    </div>
    <div>
        <table border="0" width="100%" class="table_style" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th class="th_long">
                        申请单名称
                    </th>
                    <th class="th_short">
                        申请人
                    </th>
                    <th class="th_middle">
                        流程状态
                    </th>
                    <th class="th_middle">
                        审批到达时间
                    </th>
                    <th class="th_middle">
                        审批完成时间
                    </th>
                    <th>
                        备注
                    </th>
                    <th class="th_middle">
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                    System.Data.DataTable dt_wfworked = ViewData["dt_wfworked"] as System.Data.DataTable;
                    if (dt_wfworked == null || dt_wfworked.Rows.Count == 0)
                    {%>
                <tr>
                    <td colspan="0" style="text-align: center;">
                        当前无数据！
                    </td>
                </tr>
                <% }
                    else
                    {
                        for (int i = 0; i < dt_wfworked.Rows.Count; i++)
                        {
                %>
                <tr>
                    <td>
                        <%=dt_wfworked.Rows[i]["流程名称"]%>
                    </td>
                    <td>
                        <%=dt_wfworked.Rows[i]["发起人"]%>
                    </td>
                    <td>
                        <%=dt_wfworked.Rows[i]["任务名称"]%>
                    </td>
                    <td>
                        <%=DateTime.Parse(dt_wfworked.Rows[i]["开始时间"].ToString()).ToString("yyyy-MM-dd HH:mm")%>
                    </td>
                    <td>
                        <%=DateTime.Parse(dt_wfworked.Rows[i]["完成时间"].ToString()).ToString("yyyy-MM-dd HH:mm")%>
                    </td>
                    <td title='<%=dt_wfworked.Rows[i]["备注"].ToString() %>'>
                        <%=dt_wfworked.Rows[i]["备注"].ToString().Length > 25 ? dt_wfworked.Rows[i]["备注"].ToString().Remove(25) : dt_wfworked.Rows[i]["备注"].ToString()%>
                    </td>
                    <td>
                        <%--<%=Ajax.ActionLink("查看", "WFTaskDetails",
                        new { uniqueId = dt_wfworked.Rows[i]["实例标识"] },
                                                    new AjaxOptions { UpdateTargetId = "workarea-2-5", OnSuccess = "addtab('2-5','查看流程')" }, new { @class = "btn_detail" })%>--%>
                        <a onclick="checkProcedure('<%=dt_wfworked.Rows[i]["实例标识"] %>')" class="btn_detail">
                            审批状态</a>
                    </td>
                </tr>
                <%
                    }
                    }%>
            </tbody>
        </table>
    </div>
    <div id="pageLink">
        <%var pageInfo = ViewData["pageInfo"] as PagingInfo;%>
        <%if (pageInfo != null)
          { %>
        <%=Ajax.PageLinks(pageInfo, index => Url.Action("WFFinishList", new
{
    page = index,
    wfname = ViewData["searchtaskname_wffinish"],
    clrname = ViewData["searchclrname_wffinish"],
    stime = ViewData["searchstime_wffinish"],
    etime = ViewData["searchetime_wffinish"],
}), new AjaxOptions { UpdateTargetId = "workarea-2-4" })%>
        <%} %>
    </div>
    <%} %>
</div>
